Skip to content

staruhub/Healthapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Yet another healthApp

One day, one person, one project

AI-Powered Health & Nutrition Tracking

License: MIT

Python

Node.js

FastAPI

Next.js

React

PostgreSQL

Features ยท Quick Start ยท Documentation ยท ไธญๆ–‡ๆ–‡ๆกฃ


Track nutrition, exercise, and wellness with AI-powered personalized insights


โš ๏ธ Security Notice

Important: Please ensure you're using the latest security-patched versions:

  • Next.js: 16.0.10+ or 16.1.x (CVE-2025-66478)
  • React: 19.2.3+ (CVE-2025-55182, CVE-2025-55183, CVE-2025-55184)

Run npm audit regularly and keep dependencies updated.


โœจ Features

Feature Description
๐Ÿฝ๏ธ Smart Food Logging AI-powered food recognition with automatic nutrition calculation
โš–๏ธ Body Metrics Track weight, BMI, body fat percentage, and fitness progress
๐Ÿ‹๏ธ Workout Tracking Log exercises with duration, calories burned, and intensity
๐Ÿ”ฌ Ingredient Analysis Scan and analyze food ingredients for health insights
๐Ÿ“Š Analytics Dashboard Visualize trends with interactive charts and statistics
๐Ÿค– AI Health Assistant Get personalized nutrition and fitness recommendations
๐Ÿ“ฑ Mobile-First Design Responsive UI optimized for all devices
๐Ÿ” Secure Authentication JWT-based auth with token refresh mechanism

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Version Description
Next.js 16.1.x React framework with App Router & Turbopack
React 19.2.x UI library with Actions & Server Components
TailwindCSS 4.x Utility-first CSS (CSS-first config)
Zustand 5.x Lightweight state management
TanStack Query 5.x Server state management
Radix UI latest Accessible UI primitives

Backend

Technology Version Description
FastAPI 0.115+ High-performance Python web framework
PostgreSQL 15+ Relational database
SQLAlchemy 2.0 Async ORM
Alembic 1.14+ Database migrations
Pydantic 2.x Data validation
OpenAI API GPT-4 AI integration

๐Ÿš€ Quick Start

Prerequisites

Tool Version Installation
Python 3.11+ python.org
Node.js 20+ nodejs.org
pnpm 9+ npm install -g pnpm
uv Latest curl -LsSf <https://astral.sh/uv/install.sh> | sh
Docker Latest docker.com

One-Command Setup

# Clone and enter directory
git clone <https://github.com/staruhub/Healthapp.git> && cd Healthapp

# Start database
docker-compose up -d

# Terminal 1: Backend
cd backend && cp .env.example .env
uv sync && uv run alembic upgrade head
uv run uvicorn app.main:app --reload --port 8001

# Terminal 2: Frontend
cd frontend && echo "NEXT_PUBLIC_API_URL=http://localhost:8001" > .env.local
pnpm install && pnpm dev

๐ŸŽ‰ Access the app:


โš™๏ธ Configuration

Backend .env

# Database
DATABASE_URL=postgresql+asyncpg://healthapp:healthapp_dev_2024@localhost:5432/healthapp_db

# Security (REQUIRED: openssl rand -hex 32)
SECRET_KEY=your-super-secret-key-here

# AI Mode: "mock" (dev) | "real" (prod)
AI_MODE=mock
OPENAI_API_KEY=sk-...  # Required when AI_MODE=real

# CORS
CORS_ORIGINS=["<http://localhost:3000>"]

Frontend .env.local

NEXT_PUBLIC_API_URL=http://localhost:8001
NEXT_PUBLIC_AI_MODE=mock


๐Ÿ“š API Documentation

Endpoints Overview

Method Endpoint Description
POST /api/v1/auth/register User registration
POST /api/v1/auth/login User login
POST /api/v1/auth/refresh Refresh access token
GET /api/v1/food/logs Get food logs
POST /api/v1/food/parse AI food parsing
GET /api/v1/body/logs Get body metrics
GET /api/v1/dashboard/summary Dashboard data
POST /api/v1/chat AI chat assistant

Interactive documentation available at:

  • Swagger UI: GET /docs
  • ReDoc: GET /redoc
  • Health Check: GET /health

๐Ÿ“ Project Structure

Healthapp/
โ”œโ”€โ”€ backend/                    # FastAPI Backend
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/v1/            # API Routes
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.py        # Authentication
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ food.py        # Food logging
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ body.py        # Body metrics
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ workout.py     # Workout tracking
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard.py   # Dashboard
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ chat.py        # AI chat
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ingredient.py  # Ingredient analysis
โ”‚   โ”‚   โ”œโ”€โ”€ models/            # SQLAlchemy Models
โ”‚   โ”‚   โ”œโ”€โ”€ schemas/           # Pydantic Schemas
โ”‚   โ”‚   โ”œโ”€โ”€ services/ai/       # AI Service Layer
โ”‚   โ”‚   โ””โ”€โ”€ utils/             # Utilities
โ”‚   โ”œโ”€โ”€ alembic/               # Database Migrations
โ”‚   โ””โ”€โ”€ pyproject.toml
โ”‚
โ”œโ”€โ”€ frontend/                   # Next.js Frontend
โ”‚   โ”œโ”€โ”€ app/                   # App Router Pages
โ”‚   โ”‚   โ”œโ”€โ”€ (auth)/            # Auth pages
โ”‚   โ”‚   โ””โ”€โ”€ (main)/            # Main app pages
โ”‚   โ”œโ”€โ”€ components/            # React Components
โ”‚   โ”‚   โ”œโ”€โ”€ ui/                # Base UI
โ”‚   โ”‚   โ”œโ”€โ”€ chat/              # Chat components
โ”‚   โ”‚   โ””โ”€โ”€ onboarding/        # Onboarding flow
โ”‚   โ”œโ”€โ”€ hooks/                 # Custom React Hooks
โ”‚   โ”œโ”€โ”€ store/                 # Zustand State
โ”‚   โ”œโ”€โ”€ lib/                   # Utilities
โ”‚   โ””โ”€โ”€ types/                 # TypeScript Types
โ”‚
โ”œโ”€โ”€ openspec/                  # Project Specifications
โ”œโ”€โ”€ docker-compose.yml
โ””โ”€โ”€ README.md


๐Ÿ”ง Troubleshooting

Database Connection Failed
# Check container status
docker ps | grep postgres

# Restart container
docker-compose restart

# View logs
docker-compose logs postgres
Port Already in Use
# Find process
lsof -i :8001

# Kill process
kill -9 <PID>

# Or use different port
uv run uvicorn app.main:app --reload --port 8002
Frontend Cannot Connect to Backend
  1. Verify backend: curl <http://localhost:8001/health>
  2. Check NEXT_PUBLIC_API_URL in .env.local
  3. Verify CORS settings in backend .env
  4. Clear browser cache and restart
Token/Authentication Issues
# Clear stored tokens in browser
localStorage.removeItem('auth-storage')
# Then refresh the page

โ“ FAQ

What is AI_MODE?
  • mock: Returns pre-defined responses (no API costs, for development)
  • real: Uses OpenAI GPT-4 API (requires OPENAI_API_KEY)
How to reset the database?
dropdb healthapp_db && createdb healthapp_db
cd backend && uv run alembic upgrade head
How to generate a secure SECRET_KEY?
openssl rand -hex 32

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/AmazingFeature
  3. Commit changes: git commit -m 'feat: add amazing feature'
  4. Push to branch: git push origin feature/AmazingFeature
  5. Open Pull Request

Commit Convention

Type Description
feat New feature
fix Bug fix
docs Documentation
style Formatting
refactor Code refactoring
test Adding tests
chore Maintenance

๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE for details.


๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡ๆ–‡ๆกฃ

็‚นๅ‡ปๅฑ•ๅผ€ไธญๆ–‡่ฏดๆ˜Ž

ๅŠŸ่ƒฝ็‰นๆ€ง

  • ๐Ÿฝ๏ธ ๆ™บ่ƒฝ้ฃŸ็‰ฉ่ฎฐๅฝ• - AI ้ฉฑๅŠจ็š„้ฃŸ็‰ฉ่ฏ†ๅˆซ๏ผŒ่‡ชๅŠจ่ฎก็ฎ—่ฅๅ…ปๆˆๅˆ†
  • โš–๏ธ ่บซไฝ“ๆŒ‡ๆ ‡่ฟฝ่ธช - ่ฟฝ่ธชไฝ“้‡ใ€BMIใ€ไฝ“่„‚็އๅ’Œๅฅ่บซ่ฟ›ๅบฆ
  • ๐Ÿ‹๏ธ ่ฟๅŠจ่ฟฝ่ธช - ่ฎฐๅฝ•่ฟๅŠจๆ—ถ้•ฟใ€ๆถˆ่€—ๅก่ทฏ้‡Œๅ’Œ่ฟๅŠจๅผบๅบฆ
  • ๐Ÿ”ฌ ๆˆๅˆ†ๅˆ†ๆž - ๆ‰ซๆๅˆ†ๆž้ฃŸๅ“้…ๆ–™๏ผŒๆไพ›ๅฅๅบทๆดžๅฏŸ
  • ๐Ÿ“Š ๆ•ฐๆฎไปช่กจ็›˜ - ไบคไบ’ๅผๅ›พ่กจๅฏ่ง†ๅŒ–ๅฅๅบท่ถ‹ๅŠฟ
  • ๐Ÿค– AI ๅฅๅบทๅŠฉๆ‰‹ - ่Žทๅ–ไธชๆ€งๅŒ–่ฅๅ…ปๅ’Œๅฅ่บซๅปบ่ฎฎ

ๅฟซ้€Ÿๅผ€ๅง‹

# ๅ…‹้š†ไป“ๅบ“
git clone <https://github.com/staruhub/Healthapp.git> && cd Healthapp

# ๅฏๅŠจๆ•ฐๆฎๅบ“
docker-compose up -d

# ๅฏๅŠจๅŽ็ซฏ
cd backend && cp .env.example .env
uv sync && uv run alembic upgrade head
uv run uvicorn app.main:app --reload --port 8001

# ๅฏๅŠจๅ‰็ซฏ๏ผˆๆ–ฐ็ปˆ็ซฏ๏ผ‰
cd frontend && echo "NEXT_PUBLIC_API_URL=http://localhost:8001" > .env.local
pnpm install && pnpm dev

็Žฏๅขƒ่ฆๆฑ‚

ไพ่ต– ็‰ˆๆœฌ ๅฎ‰่ฃ…ๆ–นๅผ
Python 3.11+ python.org
Node.js 20+ nodejs.org
pnpm 9+ npm install -g pnpm
uv ๆœ€ๆ–ฐ็‰ˆ curl -LsSf <https://astral.sh/uv/install.sh> | sh
Docker ๆœ€ๆ–ฐ็‰ˆ docker.com

staruhub

โญ Star this repo if you find it helpful! โญ

About

One lightweight health app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors